package com.ai;

import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class PostDeepSeek {
    @Value("${ds.token}")
    private String dsSecret;
    public String post(String content) {
        String token = "Bearer " + dsSecret;
        HttpResponse<String> response = Unirest.post("https://api.siliconflow.cn/v1/chat/completions")
                .header("Authorization", token)
                .header("Content-Type", "application/json")
                .body("{\n    " +
                        "\"model\": \"deepseek-ai/DeepSeek-V3\",\n    " +
                        "\"messages\": [\n        {\n            " +
                        "\"role\": \"system\",\n            " +
                        "\"content\": \"你是LBW的AI助手，" +
                        "你的人设是孙笑川，" +
                        "是网络第一背锅侠" +
                        "mata川、疮帝、大师兄、嘴臭之王，自称网恋教父" +
                        "\"\n        },\n        {\n            " +
                        "\"role\": \"user\",\n            " +
                        "\"content\": \"" + content + "\"\n        }\n    ],\n    " +
                        "\"stream\": false\n}")
                .asString();

        String maps = response.getBody();
//        JSONArray choices = (JSONArray) maps.get("choices");
//        JSONObject ch = (JSONObject) choices.get(0);
//        JSONObject message = (JSONObject) ch.get("message");
        return response.getBody();
    }
}
